var app = getApp();
var request = app.request;
var setting = app.globalData.setting;
var common = require('../../../utils/common.js');
var util = require('../../../utils/util.js');
import LoadMore from '../../../utils/LoadMore.js'
var load = new LoadMore;
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		shows: false,
		shopname: app.globalData.leaderInfo.shop_name,
		info: {},
		url: setting.url,
		QRcode: ''
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {
		options.shows = false;
		options.shopname = app.globalData.leaderInfo.shop_name;
		this.getinfo()
		
	},
	// 获取管理员二维码
	getQRcode() {
		let that = this
		request.get('/api/shop/getShareImg', {
			success: function(res) {
				if (res.data.status == 1) {
					that.shows = !that.shows;
					// 
					let imgcode='data:image/png;base64,' + res.data.result.qrcode
					that.setData({
						QRcode:imgcode,
						shows: that.shows
					});
					console.log(imgcode)
				}
			}
		});
	},
	// 同意或者拒绝申请
	submit(e) {
		console.log(e)
		let data = e.currentTarget.dataset
		let text = '是否' + (data.status == 1 ? '同意' : data.status == 2 ? '拒绝' : '') + data.id.nickname + '的申请'
		wx.showModal({
			title: '提示',
			content: text,
			success(res) {
				if (res.confirm) {
					let that = this
					request.get('/api/shop/auditManager', {
						data: {
							status: data.status,
							apply_id: data.id.user_id
						},
						success: function(res) {
							if (res.data.status == 1) {
								wx.showToast({
									title: '成功'
								})
								that.this.getinfo()
							}
						}
					});
				} else if (res.cancel) {}
			}
		})
	},
	yaoqingFunction(e) {
		var that = this;
		that.shows = !that.shows;
		// console.log(that.shows); 
		that.setData({
			shows: that.shows
		});
	},
	// 获取当前管理员信息
	getinfo() {
		let that = this
		request.get('/api/shop/getManagerList', {
			success: function(res) {
				if (res.data.status == 1) {
					that.setData({
						info: res.data.result
					});
				}
			}
		});
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {

	}
})